package com.nstar.timeline.components
{
	import com.nstar.timeline.vo.TickVO;
	
	import flash.display.CapsStyle;
	import flash.display.Graphics;
	import flash.display.LineScaleMode;
	
	import mx.containers.Canvas;
	import mx.events.FlexEvent;
	/**
	组件名称：时间轴轨道上的刻度线
	组件说明：在时间轴轨道上不同位置显示不同长度的刻度线
	设计时间：2010.6.6
	开发人员：Jonny
	*/
	public class Tick extends Canvas
	{
		private var _tickVO:TickVO;
		
		public function Tick()
		{
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		private function init(event:FlexEvent):void{
		}
		
		public function set tickVO(value:TickVO):void{
			this._tickVO = value;
			
			this.width = _tickVO.width;
			this.height = _tickVO.height;
		}
		
		public function get tickVO():TickVO{
			return this._tickVO;
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			if(_tickVO){
				drawTick();
			}
			
		}
		
		private function drawTick():void{
			var centerX:Number = this.width/2;
			var centerY:Number = this.height/2;
			var g:Graphics = this.graphics;
			g.clear();
			g.lineStyle(_tickVO.width,_tickVO.color,0.9,false,LineScaleMode.NORMAL,CapsStyle.NONE);
			g.moveTo(centerX,0);
			g.lineTo(centerX,_tickVO.height);
		}
		
	}
}